package bio;


import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;


/**
 * @Description: //todo
 * @Author: 张广焱
 * @Date: 2024-05-01 上午10:27
 */
public class BioServer {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket();
        //绑定端口
        serverSocket.bind(new InetSocketAddress(9090));
        //阻塞,接手外界的连接
        Socket socket = serverSocket.accept();
        while (true){
            InputStream inputStream = socket.getInputStream();
            byte[] bytes = new byte[10];
            inputStream.read(bytes);
            System.out.println("接收到的数据为:"+new String(bytes));
        }
    }
}
